package com.wyy.treeview.core;

import java.io.File;


import android.content.Context;
import android.util.Log;

public class FileUtil {

	/**
	 * 
	 * @Title: isDBFileExist
	 * @Description: TODO判断数据库文件是否存在
	 * @param @param context
	 * @param @return 设定文件
	 * @return boolean 返回类型
	 * @throws
	 */
	public static boolean isDBFileExist() {
		String path = android.os.Environment
				.getExternalStorageDirectory().getAbsolutePath()
				+ "/com.wyy.treeview/database" + File.separator;
		String DB_NAME = path + "DB.db";
		File file = new File(DB_NAME);
		long length = file.length();
		if (file.exists()) {

			if (length < 10240) {
				file.delete();
				return false;
			}
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 
	 * @Title: getFilePath
	 * @Description: TODO获取文件路径
	 * @param @param context
	 * @param @return 设定文件
	 * @return String 返回类型
	 * @throws
	 */
	public static String getFilePath() {
		String path = android.os.Environment
				.getExternalStorageDirectory().getAbsolutePath()
				+ "/com.wyy.treeview/database" + File.separator;
		String DB_NAME = path + "DB.db";
		Log.d("DATABASE_FILE", "创建数据库文件！");
		File dir = new File(path);
		if (!dir.exists()) {
			dir.mkdirs();
		}
		return DB_NAME;
	}
}
